package game.actor
{
	import away3d.containers.*;
	import away3d.core.managers.*;
	import away3d.primitives.*;
	
	import engine.asset.*;
	import engine.core.*;
	import engine.graphics.*;
	import engine.graphics.away3d.*;
	import engine.graphics.vfx.*;
	import engine.loaders.*;
	import engine.math.*;
	
	import flash.display.*;
	import flash.geom.*;
	
	import game.*;
	import game.core.*;
	import game.graphics.shader.*;
	import game.network.*;
	import game.ui.core.*;
	import game.scene.*;
	import game.asset.*;
	import game.messages.simulation.*;
	
	public class RxActor extends RxEntity
	{
		protected var m_sequence:RxSequence = null;
		protected var m_fxsequence:RxSequence = null;
		protected var m_buffsequence:RxSequence = null;
		public var m_target:RxActor;
		public var m_owner:RxActor;
		public var m_character:String = null;
		public var m_spawnerName:String = null;
		public var m_modelName:String = null;
		public var m_animSuite:String = null;
		public var m_pathMover:RxPathMover;
		public var m_attackRate:Number;
		public var m_attackEntities:Array;
		protected var m_walkSpeed:Number;
		protected var m_runSpeed:Number;
		protected var m_entityId:String;
		protected var m_aggroRadius:Number;
		protected var m_tetherRadius:Number;
		protected var m_large:Boolean;
		protected var m_basicAbility:String;
		protected var m_specialAbility:Array;
		public var m_currentAbilityPackage:int = -1;
		protected var m_attackNode:RxAttackNode;
		protected var m_radius:Number;
		protected var m_nodeIndex:int;
		protected var m_path:Array;
		protected var m_rotMover:RxRotMover;
		protected var m_healthStateId:int = 0;
		protected var m_health:Number;
		protected var m_healthMax:Number;
		protected var m_hitTime:Number;
		protected var m_dying:Boolean;
		protected var m_level:int;
		protected var m_class:String;
		protected var m_damage:Number;
		protected var m_xp:uint;
		protected var m_hitPercent:Number;
		private var m_queuingAttackCount:uint = 0;
		private var m_incomingQueueAttackMessages:Vector.<RxSimulation_QueueAttackMessage>;
		private var m_queuedAttacks:Vector.<RxSimulation_QueueAttackMessage>;
		protected var m_team:int;
		protected var m_type:String;
		protected var m_debugPos:RxVector4;
		protected var m_stateMachine:RxStateMachine;
		protected var m_view:View3D;
		protected var m_gameCamera:RxGameCamera;
		protected var m_scene:RxScene;
		protected var m_itemModels:RxCharacterModels;
		protected var m_itemChangeCallbacks:Vector.<RxCallback>;
		protected var m_itemUpdateCallbacks:Vector.<RxCallback>;
		protected var m_deathCallbacks:Vector.<RxCallback>;
		protected var m_mouseInteractCallbacks:Vector.<RxCallback>;
		protected var m_shadowplane:RxLoader3D;
		protected var m_shadowMaterial:RxMaterial;
		protected var m_editorMaterial:RxMaterial;
		protected var m_editorModel:RxLoader3D;
		protected var m_targeted:Boolean;
		protected var m_colorScale:RxVector4;
		protected var m_globalScale:Number;
		protected var m_highlightColor:RxVector4;
		protected var m_attachmentScale:Number;
		protected var m_currentAttackIndex:int;
		protected var m_currentChainAttack:String;
		protected var m_debugPath:Sprite;
		protected var m_debugCurrentPath:Array;
		public var m_sequenceNumber:uint;
		protected var m_controller:RxController;
		protected var m_entityXML:XML = null;
		protected var m_idlePath:Array;
		protected var m_debugPathIndex:int;
		protected var m_bound:RxBound = null;
		protected var m_bound2D:Rectangle = null;
		protected var m_runAbilityPath:Array = null;
		protected var m_runAbilityCheck:String = null;
		protected var m_stance:String;
		protected var m_leftHandItem:String = null;
		protected var m_rightHandItem:String = null;
		protected var m_rightHandDamage:Number = 0;
		protected var m_buffFloat:Vector.<Vector.<Number>>;
		protected var m_buffString:Vector.<Vector.<String>>;
		protected var m_knockPath:Array;
		protected var m_knockSpeed:Number;
		protected var m_knockStart:Number;
		protected var m_knockStun:Number;
		protected var m_knockHeight:Number;
		protected var m_knockActive:Boolean = false;
		protected var m_knockSequence:String = null;
		public static var s_nav:RxAssetNavNode = null;
		public static var s_disableAnimation:Boolean = false;
		public static var s_entityMap:Array = [];
		public static const TEAM_ENEMY:int = 0;
		public static const TEAM_FRIENDLY:int = 1;
		public static const TEAM_SPAWNER:int = 2;
		public static const TEAM_NEUTRAL:int = 3;
		public static const TEAM_MAX:int = 4;
		public static const BUFF_TYPE_HASTE:int = 0;
		public static const BUFF_TYPE_DAMAGE:int = 1;
		public static const BUFF_TYPE_PARRY:int = 2;
		public static const BUFF_TYPE_BLOCK:int = 3;
		public static const BUFF_TYPE_THORNS:int = 4;
		public static const BUFF_TYPE_DAMAGE_REDUCE:int = 5;
		public static const BUFF_TYPE_ARRAY_SIZE:int = 6;
		public static const LONG_TERM_BUFF_TYPE_XP:int = 6;
		public static const LONG_TERM_BUFF_TYPE_ENERGY:int = 7;
		public static const LONG_TERM_BUFF_TYPE_MAX_HEALTH:int = 8;
		public static const NUM_LONG_TERM_BUFFS:int = 3;
		public static const BUFF_FLOAT_PROPERTY_PASSIVE_BONUS:int = 0;
		public static const BUFF_FLOAT_PROPERTY_ACTIVE_TIME:int = 1;
		public static const BUFF_FLOAT_PROPERTY_ACTIVE_BONUS:int = 2;
		public static const BUFF_FLOAT_PROPERTY_ARRAY_SIZE:int = 3;
		public static const BUFF_STRING_PROPERTY_ABILITY_NAME:int = 0;
		public static const BUFF_STRING_PROPERTY_ABILITY_OVERRIDE:int = 1;
		public static const BUFF_STRING_PROPERTY_ARRAY_SIZE:int = 2;
		
		public function RxActor(phase:int, type:int, name:String = null, debugColor:int = 8421504)
		{
			var i:int = 0;
			this.m_attackEntities = new Array();
			this.m_incomingQueueAttackMessages = new Vector.<RxSimulation_QueueAttackMessage>;
			this.m_queuedAttacks = new Vector.<RxSimulation_QueueAttackMessage>;
			super(phase, type, name, debugColor);
			RxSimulation.s_sequenceNumber = RxSimulation.s_sequenceNumber + 1;
			this.m_sequenceNumber = RxSimulation.s_sequenceNumber + 1;
			this.m_colorScale = new RxVector4(1, 1, 1, 1);
			this.m_highlightColor = new RxVector4(1, 1, 1, 1);
			this.m_globalScale = 1;
			this.m_attachmentScale = 1;
			this.m_itemChangeCallbacks = null;
			this.m_itemUpdateCallbacks = null;
			this.m_xp = 0;
			this.m_targeted = false;
			this.m_buffFloat = new Vector.<Vector.<Number>>(BUFF_TYPE_ARRAY_SIZE);
			this.m_buffString = new Vector.<Vector.<String>>(BUFF_TYPE_ARRAY_SIZE);
			var j:int = 0;
			while (j < BUFF_TYPE_ARRAY_SIZE)
			{
				
				this.m_buffFloat[j] = new Vector.<Number>(BUFF_FLOAT_PROPERTY_ARRAY_SIZE);
				this.m_buffString[j] = new Vector.<String>(BUFF_STRING_PROPERTY_ARRAY_SIZE);
				i = 0;
				while (i < BUFF_FLOAT_PROPERTY_ARRAY_SIZE)
				{
					
					this.m_buffFloat[j][i] = 0;
					i++;
				}
				i = 0;
				while (i < BUFF_STRING_PROPERTY_ARRAY_SIZE)
				{
					
					this.m_buffString[j][i] = null;
					i++;
				}
				j++;
			}
		}
		
		public function GetPlayerIndex() : int
		{
			return -1;
		}
		
		public static function Initialize(type:int) : void
		{

		}
		
		protected function IsViewerLocalHero() : Boolean
		{
			if (RxSimulation.GetPlayerIndex() == this.GetPlayerIndex())
			{
				return true;
			}
			return false;
		}
		
		public static function GetBuffTypeFromString(val:String) : int
		{
			var buffType:int = BUFF_TYPE_ARRAY_SIZE;
			switch(val)
			{
				case "haste":
				{
					buffType = BUFF_TYPE_HASTE;
					break;
				}
				case "damage":
				{
					buffType = BUFF_TYPE_DAMAGE;
					break;
				}
				case "parry":
				{
					buffType = BUFF_TYPE_PARRY;
					break;
				}
				case "block":
				{
					buffType = BUFF_TYPE_BLOCK;
					break;
				}
				case "thorns":
				{
					buffType = BUFF_TYPE_THORNS;
					break;
				}
				case "damagereduce":
				{
					buffType = BUFF_TYPE_DAMAGE_REDUCE;
					break;
				}
				default:
				{
					break;
				}
			}
			return buffType;
		}
		
		public function UpdateAttachments(param1:Number) : void
		{
			var _loc_2:RxLoader3D = null;
			if (this.m_itemModels != null)
			{
				_loc_2 = this.m_itemModels.GetModel(RxCharacterModels.SLOT_MAIN);
				if (_loc_2 != null && _loc_2.IsVisible())
				{
					this.m_itemModels.UpdateAttachments(this.m_colorScale, this.m_attachmentScale);
				}
			}
			this.ExecuteUpdateCallbacks(param1);
		}
		
		protected function ExecuteUpdateCallbacks(param1:Number) : void
		{
			var _loc_2:RxCallback = null;
			if (this.m_itemUpdateCallbacks != null)
			{
				for each (_loc_2 in this.m_itemUpdateCallbacks)
				{
					
					_loc_2.m_function(param1);
				}
			}
		}
		
		public function isDying() : Boolean
		{
			return this.m_dying;
		}
		
		public function isVisible() : Boolean
		{
			var _loc_2:RxLoader3D = null;
			if (RxClientVars.GetInt("layoutEditor") == 1)
			{
				return true;
			}
			var _loc_1:Boolean = false;
			if (this.m_itemModels != null)
			{
				_loc_2 = this.m_itemModels.GetModel(RxCharacterModels.SLOT_MAIN);
				if (_loc_2 != null)
				{
					_loc_1 = _loc_2.IsVisible();
				}
			}
			return _loc_1;
		}
		
	}
}